Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

module.exports   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
/**
2
 * RS extensions to Date
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.Date.jsonProps.push('normalized');
8
  
9
  // Override init() so that we can deserialize normalized values
10
  var oldInit = GedcomX.Date.prototype.init;
11
  GedcomX.Date.prototype.init = function(json){
12
    oldInit.call(this, json);
13
    if(json){
14
      this.setNormalized(json.normalized);
15
    }
16
  };
17
  
18
  /**
19
   * Set the normalized values
20
   * 
21
   * @param {TextValue[]} normalized
22
   * @return {Date} this
23
   */
24
  GedcomX.Date.prototype.setNormalized = function(normalized){
25
    return this._setArray(normalized, 'normalized', 'addNormalized');
26
  };
27
  
28
  /**
29
   * Add a normalized value
30
   * 
31
   * @param {TextValue} normalized
32
   * @return {Date} this
33
   */
34
  GedcomX.Date.prototype.addNormalized = function(normalized){
35
    return this._arrayPush(normalized, 'normalized', GedcomX.TextValue);
36
  };
37
  
38
  /**
39
   * Get the normalized values
40
   * 
41
   * @return {TextValue[]}
42
   */
43
  GedcomX.Date.prototype.getNormalized = function(){
44
    return this.normalized || [];
45
  };
46
  
47
};